import Vue from 'vue'
import Vuex from 'vuex'
import axios from 'axios'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    news: [],
   
  },
  mutations: {
    refreshData(state, item) {
      state.news = [...item]
    }
  },
  actions: {
    refreshData(context, keywords) {
      axios.get("http://api.kudesoft.cn/news/list", {
        params: {
          page: 1,
          kw: keywords
        }
      }).then(res => {
        console.log(res.data.result.data);
      context.commit('refreshData',res.data.result.data)

      })
    }
  },
  modules: {
  }
})
